package com.runshu.newsmartark.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.runshu.newsmartark.R;
import com.runshu.newsmartark.entity.PhysicaInfoEntity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Demo class
 *
 * @author yu
 * @date 2020/10/27
 * @decs：
 */

public class PhyInfoAdapter extends BaseQuickAdapter<PhysicaInfoEntity.NodesBean, PhyInfoAdapter.MyViewHolder> {
    public PhyInfoAdapter(@Nullable List<PhysicaInfoEntity.NodesBean> data) {
        super(R.layout.item_trace, data);
    }

    @Override
    protected void convert(MyViewHolder helper, PhysicaInfoEntity.NodesBean item) {
        if (0 == helper.getAdapterPosition()) {
            helper.mAcceptStationTv.setTextColor(mContext.getResources().getColor(R.color.color_1677FF));
            helper.mDotIv.setImageResource(R.mipmap.dot_blue);
        } else {
            helper.mAcceptStationTv.setTextColor(mContext.getResources().getColor(R.color.color_555555));
            helper.mDotIv.setImageResource(R.mipmap.dot_gray);

        }

        helper.mAcceptStationTv.setText(item.getDetail());
        helper.mAcceptTimeTv.setText(item.getNodeTime());
        if (helper.getAdapterPosition() == mData.size() - 1) {
            //最后一条数据，隐藏时间轴的竖线和水平的分割线
            helper.mTimeLineView.setVisibility(View.INVISIBLE);
            helper.mDividerLineView.setVisibility(View.INVISIBLE);
        }
    }

    public class MyViewHolder extends BaseViewHolder {
        @BindView(R.id.dot_iv)
        ImageView mDotIv;
        @BindView(R.id.accept_station_tv)
        TextView mAcceptStationTv;
        @BindView(R.id.accept_time_tv)
        TextView mAcceptTimeTv;
        @BindView(R.id.divider_line_view)
        View mDividerLineView;
        @BindView(R.id.empty_view)
        View mEmptyView;
        @BindView(R.id.time_line_view)
        View mTimeLineView;

        public MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}